[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                            Turbo Pascal Statements 
                       With - Field Reference Statement 

    A With statement is a type of 'shorthand' for referencing fields of a
    record.  The fields of one or more specific record variables can be
    referenced within a With statement by using the field identifiers only.
    Each variable reference within a With statement is first tested to see
    if it is a valid field of the record.  If it is a valid field, it will
    be interpreted as such even if a variable with the same name exists and
    is also accessible.

    A With statement can be used with Object types as well as Record types.

              +---------------------------+             +-----------+
      With  --| Record Variable Reference |---.  Do  --.| statement |-.
            . +---------------------------+ |           +-----------+
            |                               |
            +----------------  ,  ----------+



  EXAMPLE:  Type
               DateRecord = Record
                               Month : Byte;
                               Day   : Byte;
                               Year  : Integer;
                            End;

            Var
               Date1,
               Date2 : DateRecord;

            Begin
               With Date1 Do
                  Begin
                     Month := 01;
                     Day := 01;
                     Year := 1980
                  End;
               With Date1, Date2 Do
                  Begin
                     Month := 01;
                     Day := 01;
                     Year := 1980
                  End;
            End.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson